from typing import Dict, List, Union

# 基类，包含通用的 to_string 方法
class BaseNode:
    pass
    # def __str__(self) -> str:
    #     if hasattr(self, 'value'):
    #         return str(self.value)
    #     else :
    #         return "【NULL】"


# 定义 ASTNode 的各种类型
class ObjectNode(BaseNode):
    def __init__(self, value: Dict[str, 'ASTNode']):
        self.type = "Object"
        self.value = value

class ArrayNode(BaseNode):
    def __init__(self, value: List['ASTNode']):
        self.type = "Array"
        self.value = value

class StringNode(BaseNode):
    def __init__(self, value: str):
        self.type = "String"
        self.value = value

class NumberNode(BaseNode):
    def __init__(self, value: float):
        self.type = "Number"
        self.value = value

class BooleanNode(BaseNode):
    def __init__(self, value: bool):
        self.type = "Boolean"
        self.value = value

class NullNode(BaseNode):
    def __init__(self):
        self.type = "Null"


# 使用 Union 定义 ASTNode 类型
ASTNode = Union[ObjectNode, ArrayNode, StringNode, NumberNode, BooleanNode, NullNode]
